﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using NickLee.Common;

namespace GPCSC.Web.sjsbyes
{
    public partial class myfkLIst : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                f_buildGrid();
            }
        }
        protected void f_buildGrid()
        {
                        byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
           
            Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
            Hashtable htable = new Hashtable();
            htable.Add("@userid", users.CL_USER_SOID.ToString());
            DataSet ds = new DataReturn().ReturnData(htable, "sel_hdafklist_all");

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dbRow in ds.Tables[0].Rows)
                    {
                        if (dbRow["fkistj"].ToString() == "0")
                        {
                            dbRow["ViewUrl"] = "<div style=\" cursor:pointer;\" onclick='tj(\"" + dbRow["hdsid"].ToString() + "\",\"0\")'>[未提交]</div>";
                            dbRow["dbsx"] = "<input type=\"button\" class=\"buttonCss\"  onclick='tj(\"" + dbRow["hdsid"].ToString() + "\",\"0\")' value=\"请提交\"   />";
                            
                        }
                        else if (dbRow["fkistj"].ToString() == "1")
                        {
                            dbRow["ViewUrl"] = "<div style=\" cursor:pointer;\" onclick='tj(\"" + dbRow["hdsid"].ToString() + "\",\"1\")'>[已提交]</div>";
                           // dbRow["dbsx"] = "<input type=\"button\" class=\"buttonCss\"   value=\"已提交\"   />";
                        }
                        else if (dbRow["fkistj"].ToString() == "" || dbRow["fkistj"].ToString() == null)
                        {
                            dbRow["ViewUrl"] = "<div style=\" cursor:pointer;\" onclick='tj(\"" + dbRow["hdsid"].ToString() + "\",\"2\")'>[未填写]</div>";
                            dbRow["dbsx"] = "<input type=\"button\" class=\"buttonCss\"  onclick='tj(\"" + dbRow["hdsid"].ToString() + "\",\"2\")' value=\"请填写\"   />";
                        }
                    }
                }
                PostListS.DataSource = ds;
                PostListS.DataBind();
                this.pageinfo.InnerHtml = new FYpage().GetPageNum(ds.Tables[0], PostListS, 10);

            }
        }
        /// <summary>
        /// Callback异步加载数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LCallBack_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            SqlReadXml org = new SqlReadXml();
            try
            {
                #region 删除数据
                if (Usual.f_convertString(e.Parameters[0]) == "3")
                {
                    SqlReadXml Org = new SqlReadXml();
                    var allname = "";
                    var deptname = "";
                    try
                    {

                        var zid = Usual.f_convertString(e.Parameters[2]);
                        if (zid == "" || zid == null)
                        {

                        }
                        base.o_uiTable.Clear();
                        base.o_uiTable.Add("@hdsid", zid);


                        Org.NotDoSQL("del_hdlist_byid", base.o_uiTable);

                        this.f_buildGrid();
                    }
                    catch (System.Exception ee)
                    {


                        hfError.Value = lblProcesserMsg.Text = "删除数据失败!" + ee.Message;

                    }
                }

                else if (Usual.f_convertString(e.Parameters[0]) == "2")
                {
                    SqlReadXml Org = new SqlReadXml();//
                    var zid = Usual.f_convertString(e.Parameters[2]);
                    if (zid == "" || zid == null)
                    {
                        this.f_buildGrid();
                    }
                    else
                    {
                        string likes = e.Parameters[2].ToString();
                        likes = "%" + likes + "%";
                        Hashtable htable = new Hashtable();
                        byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                        Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                        Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                      
                        htable.Add("@userid", users.CL_USER_SOID.ToString());
                        htable.Add("@like", likes);
                        DataSet ds = Org.ReaderDataSet("sel_hdafklist_bylike", htable);

                        PostListS.DataSource = ds;
                        PostListS.DataBind();
                        this.pageinfo.InnerHtml = new FYpage().GetPageNum(ds.Tables[0], PostListS, 10);

                    }
                }
                #endregion
            }
            catch (System.Exception pexp)
            {
                throw (pexp);
            }
            //最后进行Grid数据查询并填充
            finally
            {
             
                LPanel.RenderControl(e.Output);
            }
        }
    }
}